<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>{{ title }}</title>
</head>

<body>
  <div id="root">
    <!-- vue提供功能-- 语法糖 v-model -->
    <input type="text" v-model="username">
    <hr>
    <input type="text" v-model="password">
    <hr>
    <!-- v-model它是可以绑定对象 -->
    <input type="text" v-model="user.username">
    <hr>
    <input type="text" v-model="user.password">
    <div>{{ username }}</div>
    <button @click="adduser">添加用户</button>
  </div>
  <script src="./js/vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#root',
      // 数据源 所有的数据初始化都在这里
      data: {
        title:'aaaa',
        username: '张三',
        password: 'admin888',
        // 针对性，针对添加用户
        user: {
          username: '张三',
          password: 'admin888'
        }
      },
      methods: {
        adduser() {
          // console.log(this.$data)
          /* console.log(this.username)
          console.log(this.password) */
          console.log(this.user)
        }
      },
    })
  </script>
</body>

</html>